//获取url地址中的参数
function getSearchArg(argName) {
    // 去掉锚点连接
    let theHref = window.location.href; //http://localhost:3000/index.html?type=1#1234
    let searchStr;
    if (theHref.indexOf("#") > -1) {
        searchStr = theHref.substr(0, theHref.indexOf("#"));
    } else {
        searchStr = theHref.substr(0);
    }
    //searchStr  http://localhost:3000/index.html?type=1&sex=男
    let [, arr = ""] = searchStr.split("?");
    let argArr = arr.split("&");
    for (let i = 0; i < argArr.length; i++) {
        let smallArgArr = argArr[i].split("=");
        if (smallArgArr[0] === argName) {
            return decodeURIComponent(smallArgArr[1]);
        }
    }
    return "";
}
const host = "http://127.0.0.1:3000";
//ajax的promise封装函数
function sendAjax({type = 'get',url = '',dataType = 'json',data = null}) {
    url = host + url;
    return new Promise((resolve, reject) => {
        $.ajax({
            type,
            url,
            data,
            dataType,
            success: function (response) {
                resolve(response); //修改promise对象为成功状态并将ajax返回的json保存在promise对象中
            },
            error(err) {
                reject(err); //修改promise对象为成功状态并将ajax返回的错误消息保存在promise对象中
            }
        });
    })
}